﻿using T4UtilityBelt.Writers;

namespace T4UtilityBelt.UxDesigns.Screens.Renders.ViewModel
{
    public class EntityReadScreenRenderer : IEntityReadScreenRenderer
    {
        public void RenderParentClass(EntityReadScreen control, CodeWriter writer)
        {
            writer.Write(string.Format("ReadEntityViewModel<{0}Model, {0}Entity>", control.EntityName));
        }


        public void RenderCode(EntityReadScreen control, CodeWriter writer)
        {
            writer.Write(string.Format(@"
        public {0}ReadEntityViewModel()
            : base(null)
        {{
        }}

        public {0}ReadEntityViewModel({0}ModelParameters parameters)
            : base(parameters)
        {{
        }}

        public override ICommand ReadCommand
        {{
            get
            {{
                return new MvxRelayCommand(() => RequestNavigate<{0}ReadEntityViewModel>(new {0}ModelParameters() {{ Id = Data.Id }}));
            }}
        }}
        public override ICommand EditCommand
        {{
            get
            {{
                return new MvxRelayCommand(() => RequestNavigate<{0}UpdateEntityViewModel>(new {0}ModelParameters() {{ Id = Data.Id }}));
            }}
        }}

", control.EntityName));
        }

        public void RenderControls(EntityReadScreen control, CodeWriter writer)
        {
            control.Controls.RenderViewModelCs(writer);
        }

    }
}
